/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.mach.service.impl;

import io.jsonwebtoken.lang.Collections;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.mach.entity.DrawingUploadDetail;
import org.springblade.mach.vo.DrawingUploadDetailVO;
import org.springblade.mach.mapper.DrawingUploadDetailMapper;
import org.springblade.mach.service.IDrawingUploadDetailService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 *  服务实现类
 *
 * @author LY
 * @since 2021-03-09
 */
@Service
public class DrawingUploadDetailServiceImpl extends BaseServiceImpl<DrawingUploadDetailMapper, DrawingUploadDetail> implements IDrawingUploadDetailService {

	@Override
	public IPage<DrawingUploadDetailVO> selectDrawingAttachDetailPage(IPage<DrawingUploadDetailVO> page, DrawingUploadDetailVO drawingAttachDetail) {
		return page.setRecords(baseMapper.selectDrawingAttachDetailPage(page, drawingAttachDetail));
	}

	@Override
	public List<DrawingUploadDetail> getDeleteDetailList(Long uploadId, List<Long> attachIdList) {
		return baseMapper.getDeleteDetailList(uploadId,attachIdList);
	}

	@Override
	public List<Long> findAttachIdList(Long drawingUploadId) {
		if (drawingUploadId == null) {
			throw new ServiceException("参数不能为空!");
		}
		return baseMapper.findAttachIdList(drawingUploadId);
	}

	@Override
	@Transactional
	public Boolean deleteDrawingUploadDetail(Long drawingUploadId) {
		if (drawingUploadId == null) {
			throw new ServiceException("参数不能为空!");
		}
		baseMapper.deleteDrawingUploadDetail(drawingUploadId);
		return true;
	}

	@Override
	public Integer removeByAttachtIds(List<Long> attachIdList) {
		if (Collections.isEmpty(attachIdList)) {
			throw new ServiceException("参数不能为空!");
		}
		return baseMapper.deleteByAttachIds(attachIdList);
	}

}
